#ifndef xpack_macro_xsv
#define xpack_macro_xsv
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::macro_xsv::inc
#include"configure/switch.hpp"
#include"define/base_type.hpp"
#include"gc/private/gc_token.hpp"
#include"macro/xnew.hpp"
#include"macro/xexport.hpp"
#pragma pop_macro("xuser")

namespace mixc::macro_xsv{
    template<class item_t>
    struct static_string_holder {
    private:
        ::mixc::gc_private_gc_token::origin::gc_token_plus<false/*not need gc*/> * info;
    public:
        item_t * ptr() const {
            return (item_t *)(info + 1);
        }
        uxx length() const {
            return info->m_length;
        }
    };
}

#define __xsv__(ITEM_T,PADDING,STR)                                                             \
struct sv{                                                                                      \
    sv() : buf(PADDING STR) {                                                                   \
        xnew (this) ::mixc::gc_private_gc_token::origin::gc_token_plus<false/*not need gc*/>    \
            (sizeof(STR) / sizeof(ITEM_T) - 1);                                                 \
        static_assert(                                                                          \
            sizeof(::mixc::gc_private_gc_token::origin::gc_token_plus<false>) ==                \
            sizeof(PADDING) - sizeof(PADDING[0])                                                \
        );                                                                                      \
    }                                                                                           \
    ITEM_T buf[sizeof(PADDING STR) / sizeof(ITEM_T)];                                           \
};                                                                                              \
static sv   __mem__;                                                                            \
static sv * __tmp__ = & __mem__;                                                                \
return *(mixc::macro_xsv::static_string_holder<ITEM_T> *)(& __tmp__)

#define xsv(ITEM_T,PADDING,STR)       ([]() { __xsv__(ITEM_T, PADDING, STR); }())
#endif

xexport(mixc::macro_xsv::static_string_holder)